package me.lwn.auth.resources;

import me.lwn.auth.application.ServerSettingManager;
import me.lwn.auth.security.oauth2.server.authorization.ServerSetting;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("settings")
public class ServerSettingController {

    private final ServerSettingManager serverSettingManager;

    public ServerSettingController(ServerSettingManager serverSettingManager) {
        this.serverSettingManager = serverSettingManager;
    }

    /**
     * 保存认证服务参数
     *
     * @param serverSetting 认证服务参数对象
     */
    @PostMapping
    public ServerSetting save(@RequestBody ServerSetting serverSetting) {
        return serverSettingManager.save(serverSetting);
    }

    /**
     * 查询获取认证服务参数
     */
    @GetMapping("view")
    public ServerSetting view() {
        return serverSettingManager.get();
    }
}
